package com.example.shuiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shuiyin.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    
    /**
     * 根据用户名查询用户
     *
     * @param username 用户名
     * @return 用户对象
     */
    @Select("SELECT * FROM users WHERE username = #{username}")
    User selectByUsername(@Param("username") String username);
    
    /**
     * 根据邮箱查询用户
     */
    @Select("SELECT * FROM users WHERE email = #{email}")
    User selectByEmail(@Param("email") String email);
    
    /**
     * 根据手机号查询用户
     */
    @Select("SELECT * FROM users WHERE phone = #{phone}")
    User selectByPhone(@Param("phone") String phone);
    
    /**
     * 根据OpenID查询用户
     */
    @Select("SELECT * FROM users WHERE openid = #{openid}")
    User selectByOpenid(@Param("openid") String openid);
    
    /**
     * 根据重置令牌查询用户
     */
    @Select("SELECT * FROM users WHERE reset_token = #{resetToken} LIMIT 1")
    User selectByResetToken(@Param("resetToken") String resetToken);
} 